Imports System.Collections.Generic

Public Class Column
    Private _ColumnName As String
    Private _DataType As String
    Private _Length As Integer
    Private _FKTable As String
    Private _FKColumn As Boolean
    Private _Identity As Boolean
    Private _Persist As Boolean
    Private _PrimaryKey As Boolean

    Public Sub New()
        Me._ColumnName = Nothing
        Me._DataType = Nothing
        Me._Length = 0
        Me._FKColumn = False
        Me._FKTable = Nothing
        Me._Identity = False
        Me._Persist = True
        Me._PrimaryKey = False
    End Sub

    Public Property ColumnName() As String
        Get
            Return Me._ColumnName
        End Get
        Set(ByVal Value As String)
            Me._ColumnName = Value
        End Set
    End Property

    Public Property DataType() As String
        Get
            Return Me._DataType
        End Get
        Set(ByVal Value As String)
            Me._DataType = Value
        End Set
    End Property
    Public Property Length() As Integer
        Get
            Return Me._Length
        End Get
        Set(ByVal Value As Integer)
            Me._Length = Value
        End Set
    End Property
    Public Property FKTable() As String
        Get
            Return Me._FKTable
        End Get
        Set(ByVal Value As String)
            Me._FKTable = Value
        End Set
    End Property

    Public Property FKColumn() As Boolean
        Get
            Return Me._FKColumn
        End Get
        Set(ByVal Value As Boolean)
            Me._FKColumn = Value
        End Set
    End Property

    Public Property PrimaryKey() As Boolean
        Get
            Return Me._PrimaryKey
        End Get
        Set(ByVal value As Boolean)
            Me._PrimaryKey = value
        End Set
    End Property

    Public Property Identity() As Boolean
        Get
            Return Me._Identity
        End Get
        Set(ByVal value As Boolean)
            Me._Identity = value
        End Set
    End Property

    Public Property Persist() As Boolean
        Get
            Return Me._Persist
        End Get
        Set(ByVal value As Boolean)
            Me._Persist = value
        End Set
    End Property

    Public Overrides Function ToString() As String
        Return Me._ColumnName & " <<" & Me._DataType & ">> (" & Me._Length & ")" & vbCrLf & IIf(Me._FKColumn, "FK: " & Me._FKTable, "")
    End Function

    Public Function Attributes() As Attribute()
        Dim attrs As New List(Of Attribute)
        If Me.PrimaryKey Then
            attrs.Add(New Attribute("PrimaryKey"))
        End If
        If Me.Identity Then
            attrs.Add(New Attribute("Identity"))
        End If
        If Me.Persist Then
            attrs.Add(New Attribute("Persist"))
        End If
        Return attrs.ToArray()
    End Function


End Class
